// implemets Protocol :-)

#include "NetDefs.h"
#include "Parsing.h"

#include <string>
using std::string;

void Protocol::tc2db_enetered (Socket &sock, unsigned long id) {
	string myid = Auxiliary::toString(id);
	string send = "topcam: carentered ";
	send += myid;
	sock.SendLine(send);
	sock.ReceiveLine();
}

void Protocol::tc2db_exited (Socket &sock, unsigned long id) {
	string myid = Auxiliary::toString(id);
	string send = "topcam: carexited ";
	send += myid;
	sock.SendLine(send);
	sock.ReceiveLine();
}

void Protocol::tc2db_unparked (Socket &sock, unsigned int x, unsigned int y) {
	string send = "topcam: carunparked ";
	string xx = Auxiliary::toString(x);
	string yy = Auxiliary::toString(y);
	send = send+" " + xx + " " + yy;
	sock.SendLine(send);
	sock.ReceiveLine();
}

void Protocol::tc2db_parked (Socket &sock, unsigned long id, unsigned int x, unsigned int y)
{
	string myid = Auxiliary::toString(id);
	string xx = Auxiliary::toString(x);
	string yy = Auxiliary::toString(y);
	string send = "topcam: carparked ";
	send = send+myid+" " + xx + " " + yy;
	sock.SendLine(send);
	sock.ReceiveLine();
}


void Protocol::tc2db_video( Socket &sock , unsigned long id , string videoLocation ){
	string send = "topcam: video ";
	string myid = Auxiliary::toString(id);
	send = send+myid+" "+videoLocation;
	sock.SendLine(send);
	sock.ReceiveLine();
}


void Protocol::fc2db_entered (Socket &sock, unsigned long licenseplate) {
	string mylp = Auxiliary::toString(licenseplate);
	string send = "frontcam: carentered ";
	send += mylp;
	sock.SendLine(send);
	sock.ReceiveLine();
}

void Protocol::ui2db_carRequest (Socket &sock, unsigned long licenseplate)
{
	string mylp = Auxiliary::toString(licenseplate);
	string send = "ui: cardatarequest ";
	send += mylp;
	sock.SendLine(send);
	sock.ReceiveLine();
}

void Protocol::ui2db_plotRequest (Socket &sock)
{
	string send = "ui: plotdreq";	
	sock.SendLine(send);
	sock.ReceiveLine();
}